<template>
    <div class="statement" v-loading="loading">
        <div class="statement-top">
            <p>社保报表</p>
        </div>
        <div style="height: 60px;">
            <exportExcel :statementList="statementList" exportName="社保报表"></exportExcel>
        </div>
        <!-- 表格 -->
        <div>
           <tableList :statementList="statementList"></tableList>
        </div>
        <!-- 底部 -->
        <div class="statement-bottom">
            <el-button type="primary" @click="archiveReportList">归档报表</el-button>
            <el-button type="primary" @click="createReportList">创建报表</el-button>
            <el-button @click="$router.go(-1)">取消</el-button>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useRoute } from "vue-router"
import exportExcel from "@/components/exportExcel.vue"
import { getSocialList,createSocialReport,archiveSocialReport} from '@/api/socialApi/socialApi.js'
import { ElMOpen,ElMCloseBox } from "@/utils/fn.js"
import tableList from './components/tableList.vue'
let route = useRoute()
let loading = ref(false)
let statementList = ref([])
setTimeout(() => {
    loading.value = true
    getSocialList(route.query.id).then(res => {
        statementList.value = res.data
        loading.value = false
    }, 2000)
})
// 归档
let archiveReportList = () => {
    ElMCloseBox(`您确定要归档${route.query.id}?报表归档将覆盖上一次归档记录，无法恢复。`,'',"",archiveFn)
}
let archiveFn=()=>{
    archiveSocialReport(route.query.id).then(res => {
        console.log(res);
        ElMOpen('归档成功', "success")
    })
}
// 创建报表
let createReportList = () => {
    ElMCloseBox(`您将创建 《 ${route.query.id} 》 报表`,'',"",createFn)
}
let createFn = ()=>{
    createSocialReport(route.query.id).then((res) => {
        console.log(res);
        // ElMOpen('创建报表成功', "success")
    })
}
</script>

<style scoped lang="scss">
.statement {
    height: calc(100vh - 100px);
    width: 100%;
    background: #fff;
    padding: 20px;
    box-sizing: border-box;
    overflow: auto;
}

.statement-bottom {
    height: 60px;
    line-height: 60px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.statement-top {
    height: 60px;
    line-height: 60px;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 1px solid #eee;

    p {
        width: 100px;
        text-align: center;
        border-bottom: 2px solid #000;
    }
}

.statement-content {
    margin-top: 10px;
    width: 100%;
    height: 30px;

    button {
        float: right;
    }
}
</style>